---
layout: "default"
title: "OpaquePointer"
description: "Swift documentation for 'OpaquePointer': A wrapper around an opaque C pointer."
keywords: "OpaquePointer,struct,swift,documentation,==,debugDescription,hashValue"
root: "/v3.1"
---

<div class="intro-declaration"><code class="language-swift">struct OpaquePointer</code></div>

<div class="discussion comment">
    <p>A wrapper around an opaque C pointer.</p>

<p>Opaque pointers are used to represent C pointers to types that
cannot be represented in Swift, such as incomplete struct types.</p>
</div>

<table class="standard">
<tr>
<th id="inheritance">Inheritance</th>
<td>
<code class="inherits">CVarArg, CustomDebugStringConvertible, Equatable, Hashable</code>
<span class="viz"><a href="hierarchy/">View Protocol Hierarchy &rarr;</a></span>
</td>
</tr>



<tr>
<th>Import</th>
<td><code class="language-swift">import Swift</code></td>
</tr>

</table>


<h3>Initializers</h3>
<div class="declaration" id="init_-unsafemutablerawpointer">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_-unsafemutablerawpointer">init(<wbr>_: UnsafeMutableRawPointer)</a><div class="comment collapse" id="comment-init_-unsafemutablerawpointer"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ from: UnsafeMutableRawPointer)</code>

    </div></div>
</div>
<div class="declaration" id="init_-unsaferawpointer">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_-unsaferawpointer">init(<wbr>_: UnsafeRawPointer)</a><div class="comment collapse" id="comment-init_-unsaferawpointer"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ from: UnsafeRawPointer)</code>

    </div></div>
</div>
<div class="declaration" id="init-t_-unsafemutablepointer-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-t_-unsafemutablepointer-t">init&lt;T&gt;(<wbr>_: UnsafeMutablePointer&lt;T&gt;)</a><div class="comment collapse" id="comment-init-t_-unsafemutablepointer-t"><div class="p">
    <p>Converts a typed <code>UnsafeMutablePointer</code> to an opaque C pointer.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init&lt;T&gt;(_ from: UnsafeMutablePointer&lt;T&gt;)</code>

    </div></div>
</div>
<div class="declaration" id="init-t_-unsafepointer-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-t_-unsafepointer-t">init&lt;T&gt;(<wbr>_: UnsafePointer&lt;T&gt;)</a><div class="comment collapse" id="comment-init-t_-unsafepointer-t"><div class="p">
    <p>Converts a typed <code>UnsafePointer</code> to an opaque C pointer.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init&lt;T&gt;(_ from: UnsafePointer&lt;T&gt;)</code>

    </div></div>
</div>
<div class="declaration" id="init_-unsafemutablerawpointer">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_-unsafemutablerawpointer">init?(<wbr>_: UnsafeMutableRawPointer?)</a><div class="comment collapse" id="comment-init_-unsafemutablerawpointer"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">init?(_ from: UnsafeMutableRawPointer?)</code>

    </div></div>
</div>
<div class="declaration" id="init_-unsaferawpointer">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_-unsaferawpointer">init?(<wbr>_: UnsafeRawPointer?)</a><div class="comment collapse" id="comment-init_-unsaferawpointer"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">init?(_ from: UnsafeRawPointer?)</code>

    </div></div>
</div>
<div class="declaration" id="init-t_-unsafemutablepointer-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-t_-unsafemutablepointer-t">init?&lt;T&gt;(<wbr>_: UnsafeMutablePointer&lt;T&gt;?)</a><div class="comment collapse" id="comment-init-t_-unsafemutablepointer-t"><div class="p">
    <p>Converts a typed <code>UnsafeMutablePointer</code> to an opaque C pointer.</p>

<p>The result is <code>nil</code> if <code>from</code> is <code>nil</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init?&lt;T&gt;(_ from: UnsafeMutablePointer&lt;T&gt;?)</code>

    </div></div>
</div>
<div class="declaration" id="init-t_-unsafepointer-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-t_-unsafepointer-t">init?&lt;T&gt;(<wbr>_: UnsafePointer&lt;T&gt;?)</a><div class="comment collapse" id="comment-init-t_-unsafepointer-t"><div class="p">
    <p>Converts a typed <code>UnsafePointer</code> to an opaque C pointer.</p>

<p>The result is <code>nil</code> if <code>from</code> is <code>nil</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init?&lt;T&gt;(_ from: UnsafePointer&lt;T&gt;?)</code>

    </div></div>
</div>
<div class="declaration" id="init-bitpattern_-int">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-bitpattern_-int">init?(<wbr>bitPattern: Int)</a><div class="comment collapse" id="comment-init-bitpattern_-int"><div class="p">
    <p>Creates an <code>OpaquePointer</code> from a given address in memory.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init?(bitPattern: Int)</code>

    </div></div>
</div>
<div class="declaration" id="init-bitpattern_-uint">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-bitpattern_-uint">init?(<wbr>bitPattern: UInt)</a><div class="comment collapse" id="comment-init-bitpattern_-uint"><div class="p">
    <p>Creates an <code>OpaquePointer</code> from a given address in memory.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init?(bitPattern: UInt)</code>

    </div></div>
</div>


<h3>Instance Variables</h3>
<div class="declaration" id="var-debugdescription_-string">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-debugdescription_-string">var debugDescription: String</a><div class="comment collapse" id="comment-var-debugdescription_-string"><div class="p">
    <p>A textual representation of the pointer, suitable for debugging.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var debugDescription: String { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-hashvalue_-int">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-hashvalue_-int">var hashValue: Int</a><div class="comment collapse" id="comment-var-hashvalue_-int"><div class="p">
    <p>The pointer&#39;s hash value.</p>

<p>The hash value is not guaranteed to be stable across different
invocations of the same program.  Do not persist the hash value across
program runs.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var hashValue: Int { get }</code>

    </div></div>
</div>



<h3>Instance Methods</h3>
<div class="declaration" id="func-eqeq_rhs_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-eqeq_rhs_">func ==(<wbr>_:<wbr>rhs:)</a>
        
<div class="comment collapse" id="comment-func-eqeq_rhs_"><div class="p">
    <p>Returns a Boolean value indicating whether two values are equal.</p>

<p>Equality is the inverse of inequality. For any values <code>a</code> and <code>b</code>,
<code>a == b</code> implies that <code>a != b</code> is <code>false</code>.</p>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A value to compare.
  <strong>rhs:</strong> Another value to compare.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func ==(lhs: OpaquePointer, rhs: OpaquePointer) -&gt; Bool</code>
    
    
</div></div>
</div>


